<?php
/**
 * HTMLQuickFormView class definition
 *  
 * @author Sean Crystal <seancrystal@gmail.com>
 * @package MutantVole
 */
require_once 'interfaces/iViewRenderer.php';
require_once 'lib/HTML_QuickForm/QuickForm.php';

/**
 * View that includes an HTMLQuickForm object to assist in
 * creation of forms
 * @package MutantVole
 * @subpackage Views
 */    
class HTMLQuickFormView extends View {
	/**
     * Constructor
	 * @param iViewRenderer|null $renderer
	 * @param string $formName
	 */   	
	public function __construct(iViewRenderer $renderer = null, $formName = 'form') {
		parent::__construct($renderer);
		
		// kinda of ugly having reference to $_SERVER here
		$this->form     = new HTML_QuickForm($formName, 'POST', $_SERVER['REQUEST_URI']);
		$this->formName = $formName;
		
		$this->readOnly[] = 'form';
		$this->readOnly[] = 'formName';
		
		$this->form->addElement('hidden', 'action', null, array('id' => 'action'));
		
		$this->CreateForm();
	}
	
	/**
 	 * This method should be overridden to actually create the form	
 	 */	
	protected function CreateForm() {}
	
	/**
 	 * name and id to assign to the <form>
	 * @var string
	 */  	
	protected $formName;
	
	/**
     * HTMLQuickForm object
	 * @var HTML_QuickForm
	 */  	
	protected $form;	
}

?>